<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE xsl:stylesheet SYSTEM "lang://lenta">

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">	
	
	<xsl:include href="../main.xsl" />
	<xsl:include href="menu.xsl" />
	<xsl:include href="../common/navigation.xsl" />
	
	<!-- Запускаем рендер страницы -->
	<xsl:template match="/data">
		<html>
		
		<head>
			<title>
				<xsl:value-of select="$pageTitle" />
			</title>
			<xsl:call-template name="meta-head" />
			<link rel="stylesheet" href="{$baseURI}/css/lenta.css" type="text/css" media="all" />
		</head>
		<body>
			
			<xsl:call-template name="top-userbar" />
			
			<!-- Header -->
			<div id="header">
				<xsl:call-template name="logo" />
				
				<!-- Menu -->
				<xsl:call-template name="menu" />
			</div>
			<!-- /Header -->
			
			<!-- Blocks -->
			<div id="blocks">
				<div id="blocks_inner">
					<xsl:call-template name="default-blocks-top" />
				</div>
			</div>
			<!-- // Blocks -->
			
			<!-- Content -->
			<div id="content">
				<div id="content_inner">
					<xsl:apply-templates select="response" />
				</div>
			</div>
			<!-- // Content -->
			
			<!-- Address -->
			<xsl:call-template name="footer" />
		</body>
		</html>
	</xsl:template>
	
	<xsl:template match="response">
		<h1>&labelHeader;</h1>
		
		<div id="lenta_items">
			<xsl:if test="../@user-group = 'guest'">&labelClosed1; <a href="{$baseURI}/users/login">&labelClosed2;</a>.</xsl:if>
			<xsl:if test="../@user-group != 'guest'">
				<xsl:if test="count (object) = 0">&labelEmpty1; <a href="{$baseURI}/people">&labelEmpty2;</a>.</xsl:if>
				<xsl:apply-templates select="object" />
			</xsl:if>
		</div>
		
		<xsl:apply-templates select="pages" mode="pages-navigation">
			<xsl:with-param name="href">
				<xsl:value-of select="concat ($baseURI, '/lenta')" />
			</xsl:with-param>
		</xsl:apply-templates>
	</xsl:template>
	
	<xsl:template match="object[@type='log_article']">
		<xsl:param name="userLogin" select="property[@name='user_login']/value" />
		<xsl:param name="articleId" select="property[@name='object_id']/value" />
		<xsl:param name="blogAlias" select="property[@name='blog_alias']/value" />
		
		<div class="item post">
			<span class="date">
				<xsl:value-of select="property[@name='date']/value" />
			</span>
			<a href="{$baseURI}/user/{$userLogin}">
				<xsl:value-of select="property[@name='user_name']/value" />
			</a>
			<xsl:text> &labelAddedArticle; «</xsl:text>
			<a href="{$baseURI}/post/article/{$articleId}">
				<xsl:value-of select="property[@name='article_title']/value" disable-output-escaping="yes" />
			</a>
			<xsl:text>» &labelIn; </xsl:text>
			<xsl:if test="$blogAlias = ''">
				<a href="{$baseURI}/blogs/user/{$userLogin}">&labelPersonalBlog;</a>
			</xsl:if>
			<xsl:if test="$blogAlias != ''">
				<xsl:text>&labelBlog; </xsl:text>
				<a href="{$baseURI}/blog/{$blogAlias}">
					<xsl:value-of select="property[@name='blog_title']/value" disable-output-escaping="yes" />
				</a>
			</xsl:if>
		</div>
	</xsl:template>
	
	<xsl:template match="object[@type='log_link']">
		<xsl:param name="userLogin" select="property[@name='user_login']/value" />
		<xsl:param name="articleId" select="property[@name='object_id']/value" />
		<xsl:param name="blogAlias" select="property[@name='blog_alias']/value" />
		
		<div class="item post">
			<span class="date">
				<xsl:value-of select="property[@name='date']/value" />
			</span>
			<a href="{$baseURI}/user/{$userLogin}">
				<xsl:value-of select="property[@name='user_name']/value" />
			</a>
			<xsl:text> &labelAddedLink; «</xsl:text>
			<a href="{$baseURI}/post/link/{$articleId}">
				<xsl:value-of select="property[@name='post_title']/value" disable-output-escaping="yes" />
			</a>
			<xsl:text>» &labelIn; </xsl:text>
			<xsl:if test="$blogAlias = ''">
				<a href="{$baseURI}/blogs/user/{$userLogin}">&labelPersonalBlog;</a>
			</xsl:if>
			<xsl:if test="$blogAlias != ''">
				<xsl:text>&labelBlog; </xsl:text>
				<a href="{$baseURI}/blog/{$blogAlias}">
					<xsl:value-of select="property[@name='blog_title']/value" disable-output-escaping="yes" />
				</a>
			</xsl:if>
		</div>
	</xsl:template>
	
	<xsl:template match="object[@type='log_blog_member']">
		<xsl:param name="userLogin" select="property[@name='user_login']/value" />
		<xsl:param name="blogAlias" select="property[@name='blog_alias']/value" />
		
		<div class="item blog">
			<span class="date">
				<xsl:value-of select="property[@name='date']/value" />
			</span>
			<a href="{$baseURI}/user/{$userLogin}">
				<xsl:value-of select="property[@name='user_name']/value" />
			</a>
			<xsl:text> &labelJoinedBlog; «</xsl:text>
			<a href="{$baseURI}/blog/{$blogAlias}">
					<xsl:value-of select="property[@name='blog_title']/value" disable-output-escaping="yes" />
				</a>
			<xsl:text>»</xsl:text>
		</div>
	</xsl:template>
	
	<xsl:template match="object[@type='log_friend']">
		<xsl:param name="userLogin" select="property[@name='user_login']/value" />
		<xsl:param name="friendLogin" select="property[@name='friend_user_login']/value" />
		
		<div class="item friend">
			<span class="date">
				<xsl:value-of select="property[@name='date']/value" />
			</span>
			<a href="{$baseURI}/user/{$userLogin}">
				<xsl:value-of select="property[@name='user_name']/value" />
			</a>
			<xsl:text> &labelAddedFriend; </xsl:text>
			<a href="{$baseURI}/user/{$friendLogin}">
				<xsl:value-of select="property[@name='friend_user_name']/value" disable-output-escaping="yes" />
			</a>
		</div>
	</xsl:template>
	
	<xsl:template match="object[@type='log_photo']">
		<xsl:param name="userLogin" select="property[@name='user_login']/value" />
		<xsl:param name="albumId" select="property[@name='album_id']/value" />
		
		<div class="item photo">
			<span class="date">
				<xsl:value-of select="property[@name='date']/value" />
			</span>
			<a href="{$baseURI}/user/{$userLogin}">
				<xsl:value-of select="property[@name='user_name']/value" />
			</a>
			<xsl:text> &labelAddedPhotos; «</xsl:text>
			<a href="{$baseURI}/photoalbum/{$albumId}">
				<xsl:value-of select="property[@name='album_title']/value" />
			</a>
			<xsl:text>»</xsl:text>
			<div>
				<!--xsl:value-of select="concat ('{{photos::getLentaPreview(', property[@name='photos']/value, ',8)}}')" /-->
				<ul class="photos">
					<xsl:for-each select="document(concat('xmodule://photos/getLentaPreview/', property[@name='photos']/value, ';8'))/data/response/photos/photo">
						<li>
							<a>
								<xsl:attribute name="href">
									<xsl:value-of select="concat ($baseURI, '/photo/', id)" />
								</xsl:attribute>
								<img alt="">
									<xsl:attribute name="src">
										<xsl:value-of select="concat ($baseURI, '/thumb_40_40', path)" />
									</xsl:attribute>
								</img>
							</a>
						</li>
					</xsl:for-each>
				</ul>
			</div>
		</div>
	</xsl:template>
	
</xsl:stylesheet>